import http from '@/utils/http'

const BASE_URL = '/education/stats'

export interface LessonStatResp {
  classId: string
  className: string
  teacherId: string
  teacherName: string
  lessonStudentCount: number
  unitPrice: number
  totalPrice: number
  sumPrice: number
}

export interface LessonStatQuery {
  statsDateBegin?: string
  statsDateEnd?: string
  teacherIdList?: string
  categoryList?: string
}

export interface LessonCountStatResp {
  teacherId: string
  classId: string
  teacherName: string
  className: string
  lessonCount: number
  totalLessonCount: number
}

export interface LessonCountStatQuery {
  statsDateBegin?: string
  statsDateEnd?: string
  teacherIdList?: string
  categoryList?: string
}

export interface FullRateStatsResp {
  id: string
  classId: string
  teacherId: string
  grade: string

  teacherName: string
  className: string
  plannedStudentCount: number
  underwayStudentCount: number
  continueStudentCount: number
  fullRate: number
  computeDate: string
  confirmed: boolean

  totalClassCount: number
  totalUnderwayStudentCount: number
  totalPlannedStudentCount: number
  totalFullRate: string
}

export interface ContinueRateStatsResp {
  id: string
  classId: string
  teacherId: string
  grade: string

  teacherName: string
  className: string
  plannedStudentCount: number
  underwayStudentCount: number
  continueStudentCount: number
  continueRate: number
  computeDate: string
  confirmed: boolean

  totalClassCount: number
  totalUnderwayStudentCount: number
  totalContinueStudentCount: number
  totalContinueRate: string
}

export interface CancelRateStatsResp {
  id: string
  classId: string
  teacherId: string
  grade: string

  teacherName: string
  className: string
  underwayStudentCount: number
  totalLessonCount: number
  cancelLessonCount: number
  cancelRate: number
  computeDate: string
  confirmed: boolean

  totalClassCount: number
  totalCancelLessonCount: number
  totalTotalLessonCount: number
  totalCancelRate: string
}

export interface RestainedRateStatsResp {
  id: string
  classId: string
  teacherId: string
  grade: string
  teacherName: string
  className: string
  retainedStudentCount: number
  actualEnrollmentStudentCount: number
  retainedRate: number
  computeDate: string
  confirmed: boolean

  totalClassCount: number
  totalRetainedStudentCount: number
  totalActualEnrollmentStudentCount: number
  totalRetainedRate: string
}

export interface ClassRateStatResp {
  classId: string
  continueRate: number
  fullRate:	number
  cancelRate:	number
  retainedRate:	number
}

export interface TeacherLessonPriceStatsResp {
  classId: string
  className: string
  teacherId:	string
  teacherName:	string
  lessonStudentCount: number
  unitPrice:	number
  totalPrice:	number
}

export interface PerformanceRateStatsQuery {
  classYear?: number
  term?: string
  gradeList?: string
  categoryList?: string
  teacherIdList?: string
  saleStatusEnum?: string
}

/** @desc 查询 */
export function getTeacherLessonPriceStats(query: LessonStatQuery) {
  return http.get<LessonStatResp[]>(`${BASE_URL}/teacher/lessonPrice`, query)
}

/** @desc 查询 */
export function getTeacherLessonHourStats(query: LessonCountStatQuery) {
  return http.get<LessonCountStatResp[]>(`${BASE_URL}/teacher/lessonHour`, query)
}

/** @desc 查询 */
export function getFullRateStats(query: PerformanceRateStatsQuery) {
  return http.get<FullRateStatsResp[]>(`${BASE_URL}/performance/fullRate`, query)
}
/** @desc 查询 */
export function getContinueRateStats(query: PerformanceRateStatsQuery) {
  return http.get<ContinueRateStatsResp[]>(`${BASE_URL}/performance/continueRate`, query)
}
/** @desc 查询 */
export function getCancelRateStats(query: PerformanceRateStatsQuery) {
  return http.get<CancelRateStatsResp[]>(`${BASE_URL}/performance/cancelRate`, query)
}

/** @desc 查询 */
export function getRestainedRateStats(query: PerformanceRateStatsQuery) {
  return http.get<RestainedRateStatsResp[]>(`${BASE_URL}/performance/retainedRate`, query)
}

/** @desc 查询 */
export function getClassRateStat(id: string) {
  return http.get<ClassRateStatResp>(`${BASE_URL}/performance/${id}`)
}

/** @desc 查询 */
export function getSingleTeacherLessonPriceStats(id: string) {
  return http.get<TeacherLessonPriceStatsResp>(`${BASE_URL}/teacher/lessonPrice/${id}`)
}

export function exportSingleClassContinueStats(classId: string) {
  return http.download(`${BASE_URL}/exportSingleClassContinueStats/${classId}`)
}

export function exportSingleClassCancelStats(classId: string) {
  return http.download(`${BASE_URL}/exportSingleClassCancelStats/${classId}`)
}
